function Snake(map) {
    this.body = [];
    (function Initial(body) {
        // 添加蛇頭
        body.push({ x: 10, y: 10, color: 'red' });
        // 添加蛇尾
        body.push({ x: 9, y: 10, color: 'blue' });
        body.push({ x: 8, y: 10, color: 'blue' });
        body.push({ x: 7, y: 10, color: 'blue' });
    }) (this.body);
    this.map = map;
}
Snake.prototype.render = function () {
    // 生成新元素
    for (var i = 0; i < this.body.length; i++) {
        var unit=this.body[i];
        var div = document.createElement("div");
        div.style.left = unit.x * unit.width + "px";
        div.style.top = unit.y * unit.height + "px";
        div.style.width = unit.width + "px";
        div.style.height = unit.height + "px";
        div.style.position = "absolute";
        div.style.backgroundColor = unit.backgroundColor;
        this.map.appendChild(div);
    }
}

